package com.xiaoq.coms;

/**
 * @author xinpeng created on 16/8/1-上午10:15.
 */
public enum FrameworkErrorCode {


/*
状态码	含义	                    说明
200	    OK	                    请求成功
201	    CREATED	                创建成功
202	    ACCEPTED	            更新成功
400	    BAD REQUEST	            请求的地址不存在或者包含不支持的参数
401	    UNAUTHORIZED	        未授权
403	    FORBIDDEN	            被禁止访问
404	    NOT FOUND	            请求的资源不存在
500	    INTERNAL SERVER ERROR	 内部错误

*/

/*
    错误码	   错误信息	            含义	                                              status code
    999	    UNKNOW_V1_ERROR	      未知错误	                                             400
    1000	NEED_PERMISSION	      需要权限	                                             403
    1001	URI_NOT_FOUND	      资源不存在	                                             404
    1002	MISSING_ARGS	      参数不全	                                             400
    1003	IMAGE_TOO_LARGE	      上传的图片太大	                                         400
    1004	HAS_BAN_WORLD	      输入有违禁词	                                         400
    1005	INPUT_TOO_SHORT	      输入为空，或者输入字数不够	                             400
    1006	TARGET_NOT_FOUND	  相关的对象不存在，比如回复帖子时，发现小组被删掉了	         400
    1007	NEED_CAPTCHA	      需要验证码，验证码有误	                                 403
    1008	INVALID_CAPTCHA	      需要验证码，验证码有误	                                 403
    1009	IMAGE_WRONG_FORMAT	  照片格式有误(仅支持JPG,JPEG,GIF,PNG或BMP)	             400

*/



    UNKNOW_V1_ERROR(999,400),
    NEED_PERMISSION(1000,403),
    URI_NOT_FOUND(1001,404),
    MISSING_ARGS(1002,400),
    IMAGE_TOO_LARG(1003,400),
    HAS_BAN_WORD(1004,400),
    INPUT_TOO_SHORT(1005,400),
    TARGET_NOT_FOUND(1006,400),
    NEED_CAPTCHA(1007,403),//图形验证码
    INVALID_CAPTCHA(1008,403),//图形验证码

    NEED_VERIFICATION_CODE(1009,403),
    INVALID_VERIFICATION_CODE(1010,403),
    IMAGE_WRONG_FORMAT(1011,400),

    ACCESS_TOKEN_EXPIRED(9901,403,"访问令牌过期了"),
    INVALID_ACCESS_TOKEN(9902,403,"无效的访问令牌"),
    REFRESH_TOKEN_EXPIRED(9903,403,"刷新令牌过期了"),
    INVALID_REFRESH_TOKEN(9904,403,"无效的刷新令牌"),
    MISSING_AUTH_HEADER(9905,403,"authorization header缺失"),
    INVALID_ACCESS_TOKEN_TYPE(9906,403,"无效的令牌类型");



    public int value;
    public int httpStatus;
    public String errorMsg;

    FrameworkErrorCode(int value, int httpStatus) {
        this.value = value;
        //RFC2616中定义的HttpStatus
        this.httpStatus = httpStatus;
    }

    FrameworkErrorCode(int value, int httpStatus,String errorMsg) {
        this.value = value;
        //RFC2616中定义的HttpStatus
        this.httpStatus = httpStatus;
        this.errorMsg = errorMsg;
    }

    public int value(){
        return this.value;
    }
}
